using System.Globalization;
using UnityEngine;
using UnityEngine.UI;

namespace NL.Advanced.Binding
{
    public class UIBinding_FontColor : UIBinding
    {
        public Text _TrgText;

        protected override void SetComponentValue()
        {
            if (_TrgText == null)
            {
                _TrgText = this.GetComponent<Text>();
            }
            if (_TrgText != null)
            {
                int colorVal = 0;
                if (int.TryParse(Value, NumberStyles.HexNumber, NumberFormatInfo.CurrentInfo, out colorVal))
                {
                    _TrgText.color = new Color((colorVal >> 16 & 0xFF) / 255f, (colorVal >> 8 & 0xFF) / 255f, (colorVal & 0xFF) / 255f);
                    //ColorTranslator.FromOle(colorVal);
                }

                //_TrgText.color = Color.white
            }
        }
    }
}

